<!-- 使用明细 -->
<template>
    <div class="page-box h100 display-flex czbj">
        <p class="title-label">使用明细</p>
        <div class="mt10">
            <dxtable czWidth="240" :dataJson="dataJson" :formJson="formJson" :portUrl="portUrl" :qx="qx" ref="databale">
            </dxtable>
        </div>
    </div>
</template>
<script lang='ts' setup>
import dxtable from "./../../components/util/dxtable.vue";
import { h, ref, reactive } from "vue";
import { dxget } from "../../util/index"
import sort from "../../components/util/sort.vue";
const userList = ref([])
const initeer = () => {
    databale.value.initDataExpose();
};
const databale = ref();
// 弹窗公用该列表
let dataJson = reactive([
    {
        title: "会员所属",
        type: "select",
        search: true, // 是否在搜索栏展示
        key: "uid",
        options: [],
        render(row){
           try{
            return userList.value.filter(a=>a.value==row.uid)[0].label
           }catch(e){
            return '--'
           }
        }
    }, {
        title: "使用数量",
        key: "number",
    }, {
        title: "备注",
        key: "remark",
        search: true, // 是否在搜索栏展示
    },
    {
        title: "排序",
        width: 100,
        render(row) {
            row.databaseName = "shsymx";
            return h(sort, {
                row,
                onCallBack: () => {
                    initeer();
                },
            });
        },
    },
    {
        title: "添加时间",
        key: "addTime",
        width: "140",
        type: "daterange",
    },
]);
const Userid = localStorage.id
let portUrl = "shbq/shsymx";
const qx = {
    DeletePermissionID: "shbqsymxdel", //删除
    EditPermissionIdentifier: "shbqsymxbj", // 编辑
    NewPermissionIdentifier: "shbqsymxxz", // 新建
    ViewPermissionID: "shbqsymxck", // 查看
};
let formJson = reactive([
    {
        title: "会员所属",
        key: "uid",
        type: "select",
        required: true,
        options: []
    },
    {
        title: "使用数量",
        key: "number",
        type: "number",
        required: true,
    }, {
        title: "备注",
        key: "remark",
        type: "input",
        required: true,
    },
])
const getUserList = async () => {
    const { data }: any = await dxget("shbq/api/getUserList")
    data.map(a => {
        userList.value.push({
            label: a.name,
            value: a.id
        })
    })
    dataJson[0].options=[{
        label:"全部",
        value:''
    },
    ...userList.value
    ]
    formJson[0].options = userList.value
}
getUserList()
</script>


